package algorithms.leecode;

public class Au62 {
    public static void main(String[] args) {
        System.err.println(new Au62().uniquePaths(4,4));
    }
    public int uniquePaths(int m, int n) {

        int[] zc = new int[m];
        int[] zf = new int[m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {

                    if (j == 0) {
                        zc[j] = 1;
                    } else {
                        zc[j] = zc[j - 1] + zf[j];
                    }

            }
            zf = zc;
            zc = new int[m];
        }

        return zf[m - 1];

    }
}
